<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<script>
  function createCache() {
    const data = {};//闭包中的数据，被隐藏，不被外界访问
    return {
      set: function (key, val) {
        data[key] = val;
      },
      get: function (key) {
        return data[key];
      }
    }
  }
  const c = createCache();
  c.set('a', 100);
  console.log(c.get('a'));
</script>
</body>
</html>
